package broadCastMq;

import java.io.UnsupportedEncodingException;

import com.alibaba.rocketmq.client.exception.MQBrokerException;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.common.message.Message;
import com.alibaba.rocketmq.remoting.common.RemotingHelper;
import com.alibaba.rocketmq.remoting.exception.RemotingException;

public class BroadcastProducer {
    public static void main(String[] args) throws MQClientException, UnsupportedEncodingException, RemotingException,
            MQBrokerException, InterruptedException {
        DefaultMQProducer producer = new DefaultMQProducer("groupName");

        producer.setNamesrvAddr("127.0.0.1:9876");
        producer.setVipChannelEnabled(false);
        producer.start();
        for (int i = 0; i < 100; i++) {
            Message msg = new Message("Topictest", "TagA", "OrderId188",
                    "Hello world".getBytes(RemotingHelper.DEFAULT_CHARSET));
            SendResult sendresult = producer.send(msg);
            System.out.printf("%s%n", sendresult);
        }
        producer.shutdown();
    }
}
